package cn.sfrog.project.biz.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.sfrog.common.annotation.Log;
import cn.sfrog.common.core.controller.BaseController;
import cn.sfrog.common.core.domain.AjaxResult;
import cn.sfrog.common.core.page.TableDataInfo;
import cn.sfrog.common.enums.BusinessType;
import cn.sfrog.common.utils.poi.ExcelUtil;
import cn.sfrog.project.biz.admin.domain.BizAgencyCommission;
import cn.sfrog.project.biz.admin.service.IBizAgencyCommissionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/biz/agencyCommission")
public class BizAgencyCommissionController extends BaseController
{
    @Autowired
    private IBizAgencyCommissionService bizAgencyCommissionService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('biz:agencyCommission:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizAgencyCommission bizAgencyCommission)
    {
        startPage();
        List<BizAgencyCommission> list = bizAgencyCommissionService.selectBizAgencyCommissionList(bizAgencyCommission);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('biz:agencyCommission:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizAgencyCommission bizAgencyCommission)
    {
        List<BizAgencyCommission> list = bizAgencyCommissionService.selectBizAgencyCommissionList(bizAgencyCommission);
        ExcelUtil<BizAgencyCommission> util = new ExcelUtil<BizAgencyCommission>(BizAgencyCommission.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:agencyCommission:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizAgencyCommissionService.selectBizAgencyCommissionById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('biz:agencyCommission:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizAgencyCommission bizAgencyCommission)
    {
        return toAjax(bizAgencyCommissionService.insertBizAgencyCommission(bizAgencyCommission));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('biz:agencyCommission:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizAgencyCommission bizAgencyCommission)
    {
        return toAjax(bizAgencyCommissionService.updateBizAgencyCommission(bizAgencyCommission));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('biz:agencyCommission:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizAgencyCommissionService.deleteBizAgencyCommissionByIds(ids));
    }
}
